import constant from '@/utils/constant'
import storage from '@/utils/storage'

const device = {
	state: {
		devices: storage.get(constant.device)
	},

	mutations: {
		SET_DEVICES: (state, devices) => {
			state.devices = devices
			storage.set(constant.device, devices)
		},
		UPDATE_DEVICE_STATUS: (state, device) => {
			const did=state.devices.findIndex(d=>d.id==device.id))
			state.devices.splice(did,1,device)
			storage.set(constant.device, devices)
		}
	}
}

export default device
